package com.dcits.electronic_account.controller;

import com.dcits.electronic_account.bean.BingBank;
import com.dcits.electronic_account.service.impl.WithdrawalImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Controller
@RequestMapping("/user")
public class BingBankCardListController {

    @Autowired
    public WithdrawalImpl withdrawal;

    @RequestMapping("/bingBankCardList")
    @ResponseBody
    public List<BingBank> bingBankCardList(Model model, HttpServletRequest request) {
        String userid = request.getParameter("userid");
        System.out.println(userid);
        List<BingBank> list = null;
        //校验登录状态
        int flag = withdrawal.check_login_state(userid);
        if (flag == 1) {
            list = withdrawal.checkBingBankCard(userid);
            model.addAttribute("list", list);
            return list;
        } else {
            model.addAttribute("login_error", "未登录，请先登录");
            return list;
        }
    }
}
